﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HomeworkOpp
{
        public class Gsm
        {
            private string model;
            private string manufacturer;
            private string owner;
            private decimal price;
            
            public Battery battery =new Battery();
            public Display display= new Display();
            
            public Gsm()
            {
                
            }

            public Gsm(string model, string manufacturer, string owner, decimal price)
            {
                this.model = model;
                this.manufacturer = manufacturer;
                this.owner = owner;
                this.price = price;

            }
            public Gsm(string model,string manufacturer,string owner,decimal price,Battery battery,Display display)
            {
                this.model = model;
                this.manufacturer = manufacturer;
                this.owner = owner;
                this.price = price;
                
            }

            public decimal Price
            {
                get { return price; }
                set {
                    if (value<0)
                    {
                        throw new ArgumentException("Price must be positive or null(free)");
                    }
                this.price=value;}
            }
            
            public override string ToString()
            {
            return string.Format("Model: {0}, Manufacturer: {1},Owner: {2},Price: {3},Battery type: {4},Battery hoursIdle: {5},Battery hoursTalk: {6},Display size: {7},Display colors: {8} ",this.model,this.manufacturer,this.owner,this.price,this.battery.Model,this.battery.IdleHours,this.battery.HoursTalk,this.display.Size,this.display.Colors);
            }
            public void PrintInfo()
            {
                Console.WriteLine("gsm model:" +this.model+"; manufacturer:"+this.manufacturer+"owner"+this.owner+"price"+this.price+"battery properties "+this.battery.HoursTalk+this.battery.IdleHours+this.battery.Model+"gsm display:"+this.display.Colors+"gsm size:"+this.display.Size);
            }
        static void Main()
        {
            Gsm myGsm=new Gsm("sa-01","samsung","Antony",50m);
            myGsm.display.Size=32;
            myGsm.display.Colors = "16M";
            myGsm.battery.Model="hr-05";
            myGsm.battery.IdleHours=80;
            myGsm.battery.HoursTalk=40;
            
            Console.WriteLine("My gsm {0} made by {1} have a price {2} leva.I can talk for about {3} hours with my {4} battery.",myGsm.model,myGsm.manufacturer,myGsm.price,myGsm.battery.HoursTalk,myGsm.battery.Model );
            
            addConstructorGsm mySecondGsm = new addConstructorGsm("arenaKM800", "LG");
            Console.WriteLine(mySecondGsm.Model +" " +mySecondGsm.Owner +" "+ mySecondGsm.Price +" "+ mySecondGsm.Manufacturer);

            TypeBattery myNewGsm = new TypeBattery(TheBattery.LiIon);
            Console.WriteLine("My new gsm device have modern {0} battery.",myNewGsm.type);

            myGsm.PrintInfo();
            Iphone.IPhone4S.PrintInfo();

            Gsm[] myGsmArr = new Gsm[2];
            string[] models = { "Asha", "Galaxy" };
            decimal[] prices = { 300M, 800M };
            string[] owners = { "Tony", "Hrisi" };
            string[] manufacturers = { "China", "Indonesia" };
            for (int i = 0; i < myGsmArr.Length; i++)
            {
                myGsmArr[i] = new Gsm(models[i], manufacturers[i], owners[i], prices[i]);
                Console.WriteLine("Override to string( ):");
                Console.WriteLine(myGsmArr[i].ToString());
                Console.WriteLine("Print all info:");
                myGsmArr[i].PrintInfo();

            }
            Console.ReadKey();
        }
    }
}
